import request from '@/utils/request'

// 排班管理API

/**
 * 添加排班
 */
export function addWorkSchedule(data) {
  return request({
    url: '/work-schedule/add',
    method: 'post',
    data
  })
}

/**
 * 更新排班
 */
export function updateWorkSchedule(id, data) {
  return request({
    url: `/work-schedule/update/${id}`,
    method: 'put',
    data
  })
}

/**
 * 删除排班
 */
export function deleteWorkSchedule(id) {
  return request({
    url: `/work-schedule/delete/${id}`,
    method: 'delete'
  })
}

/**
 * 根据ID查询排班详情
 */
export function getWorkScheduleById(id) {
  return request({
    url: `/work-schedule/${id}`,
    method: 'get'
  })
}

/**
 * 获取我的排班列表
 */
export function getMyWorkSchedules() {
  return request({
    url: '/work-schedule/my-schedules',
    method: 'get'
  })
}

/**
 * 根据星期几获取我的排班列表
 */
export function getMyWorkSchedulesByDay(dayOfWeek) {
  return request({
    url: `/work-schedule/my-schedules/day/${dayOfWeek}`,
    method: 'get'
  })
}

/**
 * 获取我的周排班表
 */
export function getMyWeeklySchedule() {
  return request({
    url: '/work-schedule/my-weekly-schedule',
    method: 'get'
  })
}

/**
 * 批量设置排班
 */
export function batchSetWorkSchedules(data) {
  return request({
    url: '/work-schedule/batch-set',
    method: 'post',
    data
  })
}

/**
 * 复制排班到其他天
 */
export function copyScheduleToOtherDays(data) {
  return request({
    url: '/work-schedule/copy-schedule',
    method: 'post',
    data
  })
}

/**
 * 清空指定星期几的排班
 */
export function clearScheduleByDay(dayOfWeek) {
  return request({
    url: `/work-schedule/clear-day/${dayOfWeek}`,
    method: 'delete'
  })
}

/**
 * 获取指定星期几的已排班时间段
 */
export function getOccupiedTimeSlots(dayOfWeek) {
  return request({
    url: `/work-schedule/occupied-time-slots/${dayOfWeek}`,
    method: 'get'
  })
}